/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package sellcar;

import java.sql.*;
import javax.swing.JOptionPane;

/**
 *
 * @author Fabio Valezuela
 */
public class LoginDAO {
    private Connection connection;
    
    public LoginDAO(){
        this.connection = new ConnectionFactory().getConnection();
    }

public LoginDAO loginDAO(String usuario, String senha) throws SQLException{
       
    LoginDAO loginDAO = null;
    String sql = "SELECT * FROM tb_usuario WHERE DESC_LOGIN = ? AND SENHA = ?";
        
        PreparedStatement stmt = connection.prepareStatement(sql);
        stmt.setString(1,usuario);
        stmt.setString(2,senha);
        
        ResultSet rs = stmt.executeQuery();
        if(rs.next()){  
           new Tela_Principal().setVisible(true);
     } else JOptionPane.showMessageDialog(null, "USUÁRIO OU SENHA INCORRETO!", "ATENÇÃO!",JOptionPane.WARNING_MESSAGE);
     return loginDAO;
     
}  
   
}
